//
//  YLStatusToolBar.swift
//  weiBo
//
//  Created by 杨雷 on 2016/12/7.
//  Copyright © 2016年 Yang.L. All rights reserved.
//

import UIKit



//微博首页cell的底部toolBar
class YLStatusToolBar: UIView {
    
    var statusViewModel : YLStatusViewModel? {
        didSet{
            
            retweenBtn.setTitle(statusViewModel?.retweetCountContent, for: .normal)
            commentBtn.setTitle(statusViewModel?.commentCountContent, for: .normal)
            unlikeBtn.setTitle(statusViewModel?.unlikeCountContent, for: .normal)
            
        }
        
    }
    
    
    
    //懒加载
    //转发
    private lazy var retweenBtn : UIButton = {
        let btn = UIButton (imageName: "timeline_icon_retweet", backgroundImageName: "timeline_card_bottom_background", title: "转发", titleColor: UIColor.gray, fontSize: 14)
        return btn
    }()
    //评论
    private lazy var commentBtn : UIButton = {
        let btn = UIButton (imageName: "timeline_icon_comment", backgroundImageName: "timeline_card_bottom_background", title: "评论", titleColor: UIColor.gray, fontSize: 14)
        return btn
    }()
    //赞
    private lazy var unlikeBtn : UIButton = {
        let btn = UIButton (imageName: "timeline_icon_unlike", backgroundImageName: "timeline_card_bottom_background", title: "赞", titleColor: UIColor.gray, fontSize: 14)
        return btn
    }()
    
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func setupUI () {
        
        
        addSubview(retweenBtn)
        addSubview(commentBtn)
        addSubview(unlikeBtn)
        
        retweenBtn.snp.makeConstraints { (make) in
            make.left.top.bottom.equalTo(self)
            make.width.equalTo(commentBtn)
        }
        
        commentBtn.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(retweenBtn)
            make.left.equalTo(retweenBtn.snp.right)
            make.width.equalTo(unlikeBtn)
        }
        
        unlikeBtn.snp.makeConstraints { (make) in
            make.right.equalTo(self)
            make.top.bottom.equalTo(commentBtn)
            make.left.equalTo(commentBtn.snp.right)
            make.width.equalTo(retweenBtn)
        }
        
        let firstLineView = addLineView()
        let secondLineView = addLineView()
        
        firstLineView.snp.makeConstraints { (make) in
            make.centerX.equalTo(retweenBtn.snp.right)
            make.centerY.equalTo(self)
        }
        
        secondLineView.snp.makeConstraints { (make) in
            make.centerX.equalTo(commentBtn.snp.right)
            make.centerY.equalTo(self)
        }
        
        
    }
    
    //添加竖线方法
    private func addLineView () -> UIImageView {
        let lineView = UIImageView(image: #imageLiteral(resourceName: "timeline_card_bottom_line"))
        
        addSubview(lineView)
        
        return lineView
        
        
    }
    
    
}
